<template>
  <div>
    <div class="top">
      <van-search
        v-model="value"
        placeholder="请输入小区或地址"
        @search="onSearch"
        class="inputBox"
      >
        <template #label>
          <div @click="local">{{ address }}<van-icon name="arrow-down" /></div>
        </template>
      </van-search>
      <div @click="$router.push('/mapFind')">
        <van-icon name="location-o" color="#fff" class="address" size="25" />
      </div>
    </div>
    <van-swipe :autoplay="3000">
      <van-swipe-item v-for="(image, index) in images" :key="index">
        <img
          v-lazy="'http://liufusong.top:8080' + image.imgSrc"
          height="210px"
          width="100%"
        />
      </van-swipe-item>
    </van-swipe>
  </div>
</template>

<script>
import { swiper } from '@/api/article'

export default {
  name: 'TopNavigation',
  props: {
    address: {
      type: String
    }
  },
  async created () {
    const data = await swiper()
    this.images = data.body
  },
  data () {
    return {
      value: '',
      images: []
    }
  },
  methods: {
    onSearch () {
      this.value = ''
    },
    local () {
      this.$router.push('/cities')
    }
  }
}
</script>

<style lang="less" scoped>
.top {
  position: relative;
}
.inputBox {
  z-index: 999;
  position: absolute;
  width: 310px;
  padding: 0;
  top: 25px;
  left: 6%;
  border-radius: 5px;
}
.address {
  z-index: 999;
  position: absolute;
  top: 30px;
  right: 2%;
}
</style>
